home *** CD-ROM | disk | FTP | other *** search
/ Enter 2001 April / EnterCD4.iso / Update / SQL Server SP3 / sql70sp3i.exe / X86 / BINN / res / 1033 / sqlmmc.rll / HTML / REPFUNCS.BAS < prev    next >
Encoding:
BASIC Source File  |  1999-04-12  |  38.9 KB  |  1,061 lines

  1. Option Explicit
  2. ' **********************************************************
  3. '  repFuncs.bas
  4. '
  5. '  Functions that work with the repository object
  6. ' **********************************************************
  7.  
  8. Const strIDbmDeployedCatalog = "{{7FCF7882-AF00-11d1-8C1E-00AA00A14D34},00002B7A}"
  9. 'Const strIDbmSchema = "{{391881E3-F894-11d0-8E76-00A0C905A4DB},0000138A}"
  10. 'Const strIDbmTable = "{{391881E3-F894-11d0-8E76-00A0C905A4DB},0000138D}"
  11. 'Const strIDbmDeployedColumn = "{{391881E3-F894-11d0-8E76-00A0C905A4DB},00001487}"
  12. 'Const strITfmTransformationPackage = "{{7FCF7882-AF00-11d1-8C1E-00AA00A14D34},00002B5B}"
  13. Const strITfmPackageExecution = "{{7FCF7882-AF00-11d1-8C1E-00AA00A14D34},00002B65}"
  14. Const strIDTSTransformationPackage = "{{EBB9995C-BA15-11d1-901B-0000F87A3B33},000032CA}"
  15. Const strIDbmSchema = "{391881E6-F894-11d0-8E76-00A0C905A4DB}"
  16. Const strIDbmTable = "{391881E8-F894-11d0-8E76-00A0C905A4DB}"
  17. Const strIDbmDeployedColumn = "{38C13CA3-E9F4-11d1-B06D-0000F87A57EE}"
  18. Const strITfmTransformationPackage = "{7FCF788E-AF00-11d1-8C1E-00AA00A14D34}"
  19. Const strPropShortExecutionID = "{{7FCF7882-AF00-11d1-8C1E-00AA00A14D34},00002B67}"
  20. Const strPropExecutionID = "{{7FCF7882-AF00-11d1-8C1E-00AA00A14D34},00002B66}"
  21. Const iInitialArraySize = 25
  22. Const iArrayIncrement = 25
  23. ' **********************************************************
  24. '  findLinGuids
  25. '
  26. '  Finds an array of Lineage Guids given a LineageLong or
  27. '  a LineageShort value
  28. ' **********************************************************
  29. Sub findLinGuids(arrLinGuids, ByVal LineageLong, ByVal LineageShort)
  30.       ReDim arrLinGuids(0)    ' in case of error or not found
  31.       Dim strSQL
  32.       Dim roTemp 'As RepositoryObject
  33.       Dim iCnt
  34.       Dim collLin
  35.       Dim iSize
  36.       Dim rReposODBC 'As IRepositoryODBC2
  37.       Dim roPackageExecution
  38.       Dim roShortExecutionID
  39.       Dim roExecutionID
  40.       Dim roPropExecutionID
  41.       Dim roPropShortExecutionID
  42.       Dim strStorageTable
  43.       Dim strExecutionIDCol
  44.       Dim strShortExecutionIDCol
  45.       Dim rTempRepos
  46.       
  47.         ' get the appropriate table and column names from the TIM objects
  48.           Set roPackageExecution = rRepos.object(strITfmPackageExecution)
  49.           strStorageTable = roPackageExecution("IInterfaceDef").TableName
  50.           Set roPackageExecution = Nothing
  51.           Set roPropExecutionID = rRepos.object(strPropExecutionID)
  52.           strExecutionIDCol = roPropExecutionID("IPropertyDef").ColumnName
  53.           Set roPropExecutionID = Nothing
  54.           Set roPropShortExecutionID = rRepos.object(strPropShortExecutionID)
  55.           strShortExecutionIDCol = roPropShortExecutionID("IPropertyDef").ColumnName
  56.           Set roPropShortExecutionID = Nothing
  57.            
  58.           Set rTempRepos = rRepos
  59.           Set rReposODBC = objSQLNSContext.QueryInterfaceScriptObject(rTempRepos, "{8780D159-B879-11D1-98BA-00C04FC30B4A}")
  60.           Set rTempRepos = Nothing
  61.                         
  62.           strSQL = "SELECT RTblVersions.IntID from RTblVersions,  " & _
  63.                   strStorageTable & _
  64.                   " where RTblVersions.IntID = " & _
  65.                   strStorageTable & ".IntID and "
  66.   
  67.           If (Trim(LineageLong) <> "") Then
  68.             ' use the LineageLong
  69.             strSQL = strSQL & strStorageTable & "." & strExecutionIDCol & _
  70.             " = '" & LineageLong & "'"
  71.           Else
  72.             ' use the LineageShort
  73.             strSQL = strSQL & strStorageTable & "." & strShortExecutionIDCol & _
  74.                 " = " & LineageShort
  75.           End If
  76.   
  77.           'On Error Resume Next
  78.           Set collLin = rReposODBC.ExecuteQuery(strSQL)
  79.           iSize = 0
  80.           iSize = collLin.Count
  81.           On Error GoTo 0
  82.           If iSize < 0 Then iSize = 0
  83.           ReDim arrLinGuids(iSize)
  84.           
  85.           For iCnt = 0 To iSize - 1
  86.             Set roTemp = collLin(iCnt + 1)
  87.             arrLinGuids(iCnt) = GetOIDString(roTemp.VersionID)
  88.             Set roTemp = Nothing
  89.           Next
  90.   
  91.           Set collLin = Nothing
  92.           
  93.         Exit Sub
  94.   
  95. End Sub
  96.  
  97.  
  98. ' **********************************************************
  99. '  getPackageGuidFromLin
  100. '
  101. '  Finds a Version GUID given a Lineage GUID.
  102. ' **********************************************************
  103. Function getPackageGuidFromLin(ByVal strLinGuid)
  104.     Dim roTemp
  105.     
  106.     Set roTemp = rRepos.Version(strLinGuid)
  107.     On Error Resume Next 'ignore not found - though it is pretty bad
  108.     getPackageGuidFromLin = GetOIDString(roTemp.Interface("ITfmPackageExecution").TransformationPackage(1).VersionID)
  109.     On Error GoTo 0
  110.     Set roTemp = Nothing
  111.             
  112. End Function
  113.  
  114.  
  115. ' **********************************************************
  116. '  getPackageGuidFromVers
  117. '
  118. '  Finds a Package GUID given a Version GUID.
  119. ' **********************************************************
  120. Function getPackageGuidFromVers(ByVal strVerGuid)
  121.     'Dim roTemp
  122.  
  123.     'Set roTemp = rRepos.Version(strVerGuid)
  124.     'getPackageGuidFromVers = GetOIDString(roTemp.ObjectVersions(1))
  125.     'Set roTemp = Nothing
  126.     
  127.     getPackageGuidFromVers = strVerGuid    
  128.       
  129. End Function
  130. ' **********************************************************
  131. '  getPackageGuids
  132. '
  133. '  finds all the packages in the repository
  134. ' **********************************************************
  135. Function getPackageGuids(arrPacks)
  136.    ReDim arrPacks(0) ' in case of error or not found
  137.       Dim roITransformationPackage
  138.  
  139.       'get the object that represents ITransformationPackage in the repository
  140.       Set roITransformationPackage = rRepos.object(strIDTSTransformationPackage)
  141.       
  142.       AddObjInstToArray arrPacks, roITransformationPackage, 0, False
  143.  
  144.       Set roITransformationPackage = Nothing
  145.       
  146. End Function
  147.  
  148.  
  149. ' **********************************************************
  150. '  getPackageNameDesc
  151. '
  152. '  Finds Package Name and Description given its GUID
  153. ' **********************************************************
  154. Sub getPackageNameDesc(strName, strDesc, ByVal strGuid)
  155.         GetNameDescription strName, strDesc, strGuid
  156. End Sub
  157.  
  158. ' **********************************************************
  159. '  getPackageProperties
  160. '
  161. '  Gets the propery values of a version given its GUID
  162. ' **********************************************************
  163. Sub getPackageProperties(arrPackPropValues, ByVal strPackageGUID)
  164.       ReDim arrPackPropValues(13)     ' blank values in case of error or not found
  165.  
  166.       Dim roPackageVer 'As RepositoryObject
  167.       Dim roPackage 'As RepositoryObject
  168.       Dim roTemp 'As RepositoryObjectVersion
  169.         
  170.         'This will get us the latest (according to the repository rules) version of the package in the repository
  171.         Set roPackageVer = rRepos.Version(strPackageGUID)
  172.         
  173.         'Now we need to get the first version, to show the original package create time
  174.         
  175.         Set roPackage = roPackageVer.ObjectVersions(1)
  176.         
  177.              
  178.         arrPackPropValues(0) = roPackageVer.Name            'Name
  179.         arrPackPropValues(1) = roPackageVer("IUmlElement").TaggedValues("PackageVersionID").Interface("IUmlTaggedValue").Value 'Version
  180.         arrPackPropValues(2) = roPackageVer("ISummaryInformation").ShortDescription        'Description
  181.         arrPackPropValues(3) = roPackageVer("ISummaryInformation").Comments    'Comments
  182.         arrPackPropValues(4) = roPackageVer("IGenSummaryInformation").Author   'Author
  183.         arrPackPropValues(5) = roPackageVer("IGenSummaryInformation").OwnerInformation       'Author Information
  184.         arrPackPropValues(6) = roPackageVer("IVersionAdminInfo").CreateByUser  'Create By User
  185.         arrPackPropValues(7) = roPackageVer("IVersionAdminInfo").ModifyByUser  'Modified By User
  186.         arrPackPropValues(8) = roPackageVer("IVersionAdminInfo").VersionCreateTime 'Version Create Time
  187.         arrPackPropValues(9) = roPackageVer("IVersionAdminInfo").VersionModifyTime  'Version Modified Time
  188.         arrPackPropValues(10) = roPackage("IVersionAdminInfo").VersionCreateTime 'Package Creation Date
  189.         arrPackPropValues(11) = roPackageVer("IDtsTransformationPackage").PackageID  'PackageVerID
  190.         arrPackPropValues(12) = roPackageVer("IDtsTransformationPackage").ExceptionLog  'Exception Log
  191.         arrPackPropValues(13) = roPackageVer.IsFrozen
  192.         
  193.         Set roPackage = Nothing
  194.         Set roTemp = Nothing
  195.         Set roPackageVer = Nothing
  196. End Sub
  197.  
  198.  
  199. ' **********************************************************
  200. '  getPackageVermodtime
  201. '
  202. '  Gets the propery value VersionModifyTime of a version given its GUID
  203. ' **********************************************************
  204. Sub getPackageVermodtime(strVermodtime, ByVal strPackageGUID)
  205.     Dim roPackageVer 'As RepositoryObject
  206.  
  207.     'This will get us the latest (according to the repository rules) version of the package in the repository
  208.     Set roPackageVer = rRepos.Version(strPackageGUID)
  209.  
  210.     'strVermodtime = roPackageVer("IVersionAdminInfo").VersionModifyTime  'Version Modified Time
  211.      ' 10/14/98 decided to use create time due to times appearing funny because of the way the dates are set by the 
  212.      '   package save
  213.     strVermodtime = roPackageVer("IVersionAdminInfo").VersionCreateTime  'Version Created Time
  214.  
  215.  
  216.     Set roPackageVer = Nothing
  217. End Sub
  218.  
  219.  
  220. ' **********************************************************
  221. '  getLinProperties
  222. '
  223. '  Gets the propery values of a Lineage given its GUID
  224. ' **********************************************************
  225. Sub getLinProperties(arrLinPropValues, ByVal strLinGuid)
  226.         ReDim arrLinPropValues(5)       ' blank values in case of error or not found
  227.         
  228.         Dim roTemp
  229.  
  230.         Set roTemp = rRepos.Version(strLinGuid)
  231.     
  232.         arrLinPropValues(0) = roTemp.Name  'Name
  233.         arrLinPropValues(1) = roTemp("ITfmPackageExecution").ExecutionID       'Lineage Long
  234.         arrLinPropValues(2) = roTemp("ITfmPackageExecution").ShortExecutionID  'Lineage Short
  235.         arrLinPropValues(3) = roTemp("ITfmPackageExecution").System             'System
  236.         arrLinPropValues(4) = roTemp("ITfmPackageExecution").Account             'Account
  237.         arrLinPropValues(5) = roTemp("ITfmPackageExecution").WhenExecuted      'Execution Time
  238.         
  239.         Set roTemp = Nothing
  240.         
  241. End Sub
  242.  
  243.  
  244. ' **********************************************************
  245. '  getVersionName
  246. '
  247. '  Gets the name of the version given its GUID
  248. ' **********************************************************
  249. Sub getVersionName(strVersionName, ByVal strVersionGuid)
  250.     Dim roTemp
  251.     
  252.     Set roTemp = rRepos.Version(strVersionGuid)
  253.     'On Error Resume Next
  254.     strVersionName = roTemp.Name
  255.     On Error GoTo 0
  256.     Set roTemp = Nothing
  257.         
  258. End Sub
  259.  
  260.  
  261. ' **********************************************************
  262. '  getLinName
  263. '
  264. '  Gets the name of the lineage given its GUID
  265. ' **********************************************************
  266. Sub getLinName(strLineageName, ByVal strLinGuid)
  267.     Dim roTemp
  268.     
  269.     Set roTemp = rRepos.Version(strLinGuid)
  270.     'On Error Resume Next
  271.     strLineageName = roTemp.Name
  272.     On Error GoTo 0
  273.     Set roTemp = Nothing
  274.         
  275. End Sub
  276.  
  277. ' **********************************************************
  278. '  findVersionGuids
  279. '
  280. '  Finds all the other Versions given a version GUID
  281. ' **********************************************************
  282. Sub findVersionGuids(arrVersions, ByVal strPackageGUID)
  283.       ReDim arrVersions(0)    ' in case of error or not found
  284.       Dim roTemp
  285.       Dim roVersion
  286.       Dim iCnt
  287.       
  288.       Set roTemp = rRepos.Version(strPackageGUID)
  289.       iCnt = roTemp.ObjectVersions.Count
  290.       If iCnt < 0 Then iCnt = 0
  291.       ReDim arrVersions(iCnt)
  292.       iCnt = 0
  293.       For Each roVersion In roTemp.ObjectVersions
  294.         arrVersions(iCnt) = GetOIDString(roVersion.VersionID)
  295.         Set roVersion = Nothing
  296.         iCnt = iCnt + 1
  297.       Next
  298.       Set roTemp = Nothing
  299.        
  300. End Sub
  301.  
  302.  
  303. ' **********************************************************
  304. '  findLineageGuids
  305. '
  306. '  Finds all the Lineages given a version GUID
  307. ' **********************************************************
  308. Sub findLineageGuids(arrLineages, ByVal strVersionGuid)
  309.       ReDim arrLineages(0)    ' in case of error or not found
  310.       Dim roTemp
  311.       Dim roLineage
  312.       Dim iCnt
  313.       
  314.       Set roTemp = rRepos.Version(strVersionGuid)
  315.       iCnt = roTemp("ITfmTransformationPackage").Executions.Count
  316.       If iCnt < 0 Then iCnt = 0
  317.       ReDim arrLineages(iCnt)
  318.       
  319.       iCnt = 0
  320.       For Each roLineage In roTemp("ITfmTransformationPackage").Executions
  321.         arrLineages(iCnt) = GetOIDString(roLineage.VersionID)
  322.         Set roLineage = Nothing
  323.         iCnt = iCnt + 1
  324.       Next
  325.       
  326.       Set roTemp = Nothing
  327.  
  328.         
  329. End Sub
  330. ' **********************************************************
  331. '  findDbGuids
  332. '
  333. '  Finds all the Database GUIDS
  334. ' **********************************************************
  335. Sub findDbGuids(arrDbs)
  336.       ReDim arrDbs(0) ' in case of error or not found
  337.       Dim roIDbmDeployedCatalog
  338.  
  339.       'get the object that represents IDbmDeployedCatalog in the repository
  340.       Set roIDbmDeployedCatalog = rRepos.object(strIDbmDeployedCatalog)
  341.       
  342.       AddObjInstToArray arrDbs, roIDbmDeployedCatalog, 0, True
  343.  
  344.       Set roIDbmDeployedCatalog = Nothing
  345.       
  346. End Sub
  347.  
  348.  
  349. ' **********************************************************
  350. '  GetDBDataSource
  351. '
  352. ' **********************************************************
  353. Function GetDBDataSource(ByVal strGuid, strDBMSName, strDBMSVersion)
  354.     Dim roObj
  355.     Dim roPackage
  356.     Dim roDBMSSource
  357.     
  358.     
  359.     'Jason - this has been updated and it works
  360.  
  361.     Set roObj = rrepos.Version(strGuid)
  362.     GetDBDataSource = ""
  363.     On Error Resume Next
  364.     set roPackage = roObj("IUmlElement").Package(1)
  365.     GetDBDataSource = roPackage.Name
  366.     set roDBMSSource  = roPackage.Interface("IDbmDataSource").DBMS(1)
  367.     strDBMSName = roDBMSSource.Name
  368.     strDBMSVersion = roDBMSSource.Interface("IDbmDBMSNamespace").Version
  369.     set roDBMSSource = Nothing
  370.     set roPackage = Nothing
  371.     On Error GoTo 0
  372.  
  373.     Set roObj = Nothing
  374. End Function
  375.  
  376.  
  377.  
  378. Sub AddObjInstToArray(arrIn, roInterface, iSizeIn, ByVal bDatabase)
  379.       Dim roCatalog
  380.       Dim roDescendantInterface
  381.       Dim iArraySize
  382.       Dim iCnt
  383.       Dim bIsPublic
  384.       Dim iNumAdded
  385.       
  386.       'here we have to get the count and then interate throught the collection explicitly.
  387.       ' if we just do a for each on the ObjectInstances, we get IRepositoryDispatch objects back,
  388.       ' and we can't get from there to the VersionID
  389.       
  390.       'we are currently letting the repository determine the latest version for each object to
  391.       ' return to us. We could also iterate through all versions of each object returned to
  392.       ' get all versions of the databases. If we do this we would need to update the display to
  393.       ' add another level to the hierarchy to show the versions of the database.
  394.       
  395.       iArraySize = roInterface("IInterfaceDef").ObjectInstances.Count
  396.       ReDim Preserve arrIn(iArraySize + iSizeIn)
  397.       iNumAdded = 0
  398.       For iCnt = 1 To iArraySize
  399.         Set roCatalog = roInterface("IInterfaceDef").ObjectInstances(iCnt)
  400.         If bDatabase Then
  401.           'we need to check the data source for the catalog to see if it was
  402.           ' loaded as a local DTS catalog. If it was, we ignore it. The local
  403.           ' DTS catalogs do not have complete metadata, and would be confusing
  404.           ' to users.
  405.           On Error Resume Next
  406.           bIsPublic = roCatalog("IUmlElement").package(1).Interface("IDbmDataSource").IsPublic
  407.           On Error GoTo 0
  408.         End If
  409.         If bIsPublic Or Not bDatabase Then
  410.           iNumAdded = iNumAdded + 1
  411.           arrIn(iNumAdded + iSizeIn - 1) = GetOIDString(roCatalog.VersionID)
  412.         End If
  413.         Set roCatalog = Nothing
  414.       Next
  415.       'resize the array to the actual number of items
  416.       If iNumAdded <> iArraySize Then ReDim Preserve arrIn(iNumAdded + iSizeIn)
  417.       
  418.       'there is currently a bug in the repository engine where descendant interfaces aren't included when you do
  419.       ' ObjectInstances. We will explicitly iterate through each one. Note that this is a recursive function
  420.       ' in order to follow the inheritance chain all the way down.
  421.       For Each roDescendantInterface In roInterface("IInterfaceDef").Descendants
  422.         AddObjInstToArray arrIn, roDescendantInterface, iNumAdded + iSizeIn, bDatabase
  423.         Set roDescendantInterface = Nothing
  424.       Next
  425.  
  426.             
  427. End Sub
  428.  
  429.  
  430. ' **********************************************************
  431. '  getDbNameDesc
  432. '
  433. '  Finds Database Name and Description given its GUID
  434. ' **********************************************************
  435. Sub getDbNameDesc(strDbName, strDbDesc, ByVal strDbGuid)
  436.     
  437.     GetNameDescription strDbName, strDbDesc, strDbGuid
  438.     
  439. End Sub
  440.  
  441.  
  442.  
  443. Sub GetNameDescription(strName, strDesc, ByVal strGuid)
  444.     Dim roObj
  445.     
  446.     Set roObj = rRepos.Version(strGuid)
  447.        
  448.     strName = roObj.Name
  449.     strDesc = roObj("ISummaryInformation").ShortDescription
  450.     
  451.     Set roObj = Nothing
  452. End Sub
  453.  
  454. ' **********************************************************
  455. '  findSchemaGuids
  456. '
  457. '  Finds all the Schema GUIDS given a database GUID
  458. ' **********************************************************
  459. Sub findSchemaGuids(arrItems, strGuid)
  460.     ReDim arrItems(0)       ' in case of error or not found
  461.     Dim roDb
  462.     Dim roSchema
  463.     Dim iCnt
  464.     
  465.     Set roDb = rRepos.Version(strGuid)
  466.     iCnt = 0
  467.     For Each roSchema In roDb("IUmlPackage").Elements
  468.       If VerifyInterfaceSupport(roSchema, strIDbmSchema) Then
  469.         iCnt = iCnt + 1
  470.         CheckArraySize arrItems, iCnt
  471.         arrItems(iCnt - 1) = GetOIDString(roSchema.VersionID)
  472.       End If
  473.       Set roSchema = Nothing
  474.     Next
  475.     ReDim Preserve arrItems(iCnt)
  476.     Set roDb = Nothing
  477.        
  478. End Sub
  479.  
  480. ' **********************************************************
  481. '  checkarraysize
  482. '
  483. '  verifies the array is big enough, and makes it bigger if not
  484. '   uses the intialsize and increment constants to resize
  485. ' **********************************************************
  486.  
  487. Sub CheckArraySize(arrIn, iItems)
  488.  
  489.     If iItems > UBound(arrIn, 1) Then
  490.       If UBound(arrIn, 1) = 0 Then
  491.         ReDim arrIn(iInitialArraySize)
  492.       Else
  493.         ReDim Preserve arrIn(iItems + iArrayIncrement)
  494.       End If
  495.     End If
  496.   
  497. End Sub
  498.  
  499. ' **********************************************************
  500. '  VerifyInterfaceSupport
  501. '
  502. '  for some of the collections we iterate through, we can get
  503. '   things of different types. We have to check each object to make
  504. '   sure it supports the interface we need.
  505. ' **********************************************************
  506.  
  507. Function VerifyInterfaceSupport(roObject, strInterfaceGUID)
  508.   
  509.   Dim roInterfaceObj
  510.   
  511.         on error resume next
  512.     VerifyInterfaceSupport = True
  513.     Set roInterfaceObj = objSQLNSContext.QueryInterfaceScriptObject(roObject, strInterfaceGUID)
  514.     if err.number > 0 then
  515.             VerifyInterfaceSupport = False
  516.         end if    
  517.  
  518.     'For Each roInterfaceObj In rRepos.object(roObject.Type)("IClassDef").Interfaces
  519.     '  If InterfaceObjectSupportsInterface(roInterfaceObj, strInterfaceGUID) Then
  520.     '    VerifyInterfaceSupport = True
  521.     '    Set roInterfaceObj = Nothing
  522.     '    Exit For
  523.     '  End If
  524.     '  Set roInterfaceObj = Nothing
  525.     'Next
  526.   
  527. End Function
  528.  
  529.  
  530.  
  531. Function InterfaceObjectSupportsInterface(roInterfaceObj, strInterfaceGUID)
  532.  
  533.   Dim roAncestorInterface
  534.   Dim strGuid
  535.   
  536.     InterfaceObjectSupportsInterface = False
  537.     If UCase(GetOIDString(roInterfaceObj.ObjectID)) = UCase(strInterfaceGUID) Then
  538.       InterfaceObjectSupportsInterface = True
  539.     Else
  540.       On Error Resume Next
  541.       Set roAncestorInterface = roInterfaceObj("IInterfaceDef").Ancestor(1)
  542.       
  543.       strGuid = ""
  544.       strGuid = GetOIDString(roAncestorInterface.ObjectID)
  545.       If UCase(strGuid) = UCase(strInterfaceGUID) Then
  546.         InterfaceObjectSupportsInterface = True
  547.       Else
  548.         InterfaceObjectSupportsInterface = InterfaceObjectSupportsInterface(roAncestorInterface, strInterfaceGUID)
  549.       End If
  550.       On Error GoTo 0
  551.       Set roAncestorInterface = Nothing
  552.     End If
  553.  
  554. End Function
  555.  
  556. ' **********************************************************
  557. '  getSchemaNameDesc
  558. '
  559. '  Finds Schema Name and Description given its GUID
  560. ' **********************************************************
  561. Sub getSchemaNameDesc(strName, strDesc, ByVal strGuid)
  562.     GetNameDescription strName, strDesc, strGuid
  563. End Sub
  564.  
  565.  
  566. ' **********************************************************
  567. '  findTableGuids
  568. '
  569. '  Finds all the Table GUIDS given a schema GUID
  570. ' **********************************************************
  571. Sub findTableGuids(arrItems, strGuid)
  572.     ReDim arrItems(0)       ' in case of error or not found
  573.  
  574.     Dim roSchema
  575.     Dim roTable
  576.     Dim iCnt
  577.     
  578.     Set roSchema = rRepos.Version(strGuid)
  579.     iCnt = 0
  580.     For Each roTable In roSchema("IUmlPackage").Elements
  581.       If VerifyInterfaceSupport(roTable, strIDbmTable) Then
  582.         iCnt = iCnt + 1
  583.         CheckArraySize arrItems, iCnt
  584.         arrItems(iCnt - 1) = GetOIDString(roTable.VersionID)
  585.       End If
  586.       Set roTable = Nothing
  587.     Next
  588.     ReDim Preserve arrItems(iCnt)
  589.     Set roSchema = Nothing
  590. End Sub
  591.  
  592.  
  593. ' **********************************************************
  594. '  getTableNameDesc
  595. '
  596. '  Finds Table Name and Description given its GUID
  597. ' **********************************************************
  598. Sub getTableNameDesc(strName, strDesc, ByVal strGuid)
  599.         GetNameDescription strName, strDesc, strGuid
  600. End Sub
  601.  
  602.  
  603. ' **********************************************************
  604. '  findColumnGuids
  605. '
  606. '  Finds all the Column GUIDS given a table GUID
  607. ' **********************************************************
  608. Sub findColumnGuids(arrItems, strGuid)
  609.     ReDim arrItems(0)       ' in case of error or not found
  610.  
  611.     Dim roTable
  612.     Dim roColumn
  613.     Dim iCnt
  614.     
  615.     Set roTable = rRepos.Version(strGuid)
  616.     iCnt = 0
  617.     For Each roColumn In roTable("IUmlType").Members
  618.       If VerifyInterfaceSupport(roColumn, strIDbmDeployedColumn) Then
  619.         iCnt = iCnt + 1
  620.         CheckArraySize arrItems, iCnt
  621.         arrItems(iCnt - 1) = GetOIDString(roColumn.VersionID)
  622.       End If
  623.       Set roColumn = Nothing
  624.     Next
  625.     ReDim Preserve arrItems(iCnt)
  626.     Set roTable = Nothing
  627.     
  628. End Sub
  629.  
  630.  
  631. ' **********************************************************
  632. '  getColumnNameDesc
  633. '
  634. '  Finds Column Name and Description given its GUID
  635. ' **********************************************************
  636. Sub getColumnNameDesc(strName, strDesc, ByVal strGuid)
  637.         GetNameDescription strName, strDesc, strGuid
  638. End Sub
  639.  
  640.  
  641. ' **********************************************************
  642. '  getColumnProps
  643. '
  644. '  Finds Column property values given its GUID
  645. ' **********************************************************
  646. Sub getColumnProps(arrColDataValues, ByVal strGuid)
  647.         ReDim arrColDataValues(0)       ' in case of error or not found
  648.         Dim roColumn
  649.         
  650.         Set roColumn = rRepos.Version(strGuid)
  651.  
  652.         On Error Resume Next
  653.         ReDim arrColDataValues(11)
  654.         arrColDataValues(0) = roColumn.Name 'Name
  655.         arrColDataValues(1) = roColumn("ISummaryInformation").ShortDescription   'Description
  656.         arrColDataValues(2) = roColumn("ISummaryInformation").Comments  'Comments
  657.         arrColDataValues(3) = roColumn("IUmlAttribute").Type(1).Name  'DataType
  658.         arrColDataValues(4) = roColumn("IUmxAttribute").Length   'Length
  659.         arrColDataValues(5) = roColumn("IUmxAttribute").NumericScale     'Scale
  660.         arrColDataValues(6) = roColumn("IUmxAttribute").NumericPrecision 'Precision
  661.         If roColumn("IUmxAttribute").IsNullable = 0 Then
  662.           arrColDataValues(7) = "No"
  663.         ElseIf roColumn("IUmxAttribute").IsNullable = 1 Then
  664.           arrColDataValues(7) = "Yes"
  665.         Else
  666.             arrColDataValues(7) = ""
  667.         End If
  668.         arrColDataValues(8) = roColumn("IUmlMember").Type(1).Name 'Table Name
  669.         arrColDataValues(9) = roColumn("IUmlMember").Type(1)("IUmlElement").package(1).Name 'Schema Name
  670.         arrColDataValues(10) = roColumn("IUmlMember").Type(1).Interface("IUmlElement").package(1).Interface("IUmlElement").package(1).Name 'Database Name
  671.         
  672.         On Error GoTo 0
  673.         
  674.         Set roColumn = Nothing
  675. End Sub
  676.  
  677.  
  678. ' **********************************************************
  679. '  getTableProps
  680. '
  681. '  Finds Table property values given its GUID
  682. ' **********************************************************
  683. Sub getTableProps(arrTablePropValues, ByVal strTableGuid)
  684.         ReDim arrTablePropValues(0)     ' in case of error or not found
  685.         Dim roTable
  686.         
  687.         Set roTable = rRepos.Version(strTableGuid)
  688.         ReDim arrTablePropValues(5)
  689.         arrTablePropValues(0) = roTable.Name       'Name
  690.         arrTablePropValues(1) = roTable("ISummaryInformation").ShortDescription          'description
  691.         arrTablePropValues(2) = roTable("ISummaryInformation").Comments          'comments
  692.         arrTablePropValues(3) = roTable("IUmlElement").package(1).Name 'Schema Name
  693.         arrTablePropValues(4) = roTable("IUmlElement").package(1).Interface("IUmlElement").package(1).Name 'Database Name
  694.         
  695.         Set roTable = Nothing
  696. End Sub
  697.  
  698.  
  699. ' **********************************************************
  700. '  findSrcPackageGuids
  701. '
  702. '  Finds all the Source Package GUIDS given a table or
  703. '  column guid and the type which says if it is a table or
  704. '  column
  705. ' **********************************************************
  706. Sub findSrcPackageGuids(arrPackGuids, ByVal strGuid, ByVal strType)
  707.         Call findPackageGuids(arrPackGuids, strGuid, strType, "source")
  708. End Sub
  709.  
  710. ' **********************************************************
  711. '  findTgtPackageGuids
  712. '
  713. '  Finds all the Target Package GUIDS given a table or
  714. '  column guid and the type which says if it is a table or
  715. '  column
  716. ' **********************************************************
  717. Sub findTgtPackageGuids(arrPackGuids, ByVal strGuid, ByVal strType)
  718.         Call findPackageGuids(arrPackGuids, strGuid, strType, "target")
  719. End Sub
  720.  
  721. ' **********************************************************
  722. '  findPackageGuids
  723. '
  724. '  Finds all the Package GUIDS given a table or
  725. '  column guid and the type which says if it is a table or
  726. '  column, source or target is passed in
  727. ' **********************************************************
  728. Sub findPackageGuids(arrPackGuids, ByVal strGuid, ByVal strType, ByVal strDirection)
  729.         ReDim arrPackGuids(0)   ' in case of error or not found
  730.         Dim roTemp
  731.         Dim roTemp2
  732.         Dim roTemp3
  733.         Dim iTotalItems
  734.         Dim iNum, iCnt
  735.         
  736.         iTotalItems = 0
  737.         If (strType = "table") Then
  738.           FindPackages arrPackGuids, strGuid, iTotalItems, strDirection
  739.           Set roTemp = rRepos.Version(strGuid)
  740.           
  741.  'Jason - this is the old code
  742.           
  743.           'iNum = roTemp("IUmlType").Members.Count
  744.           'For iCnt = 1 To iNum
  745.           '  Set roTemp2 = roTemp("IUmlType").Members(iCnt)
  746.           '  FindPackages arrPackGuids, GetOIDString(roTemp2.VersionID), iTotalItems, strDirection
  747.           '  Set roTemp2 = Nothing
  748.           'Next
  749.   'here is the new try. Keep getting automation errors on trying to get to the version
  750.           
  751.           For each roTemp2 in roTemp("IUmlType").Members
  752.             'Set roTemp2 = roTemp3.Interface("IRepositoryObjectVersion")
  753.             FindPackages arrPackGuids, GetOIDString(roTemp2.VersionID), iTotalItems, strDirection
  754.             Set roTemp2 = Nothing
  755.           Next
  756.           
  757.   'End Jason
  758.   
  759.           
  760.           Set roTemp = Nothing
  761.         Else    'column
  762.           FindPackages arrPackGuids, strGuid, iTotalItems, strDirection
  763.           Set roTemp = rRepos.Version(strGuid)
  764.           iNum = roTemp("IUmlMember").Type.Count
  765.           For iCnt = 1 To iNum
  766.             Set roTemp2 = roTemp("IUmlMember").Type(iCnt)
  767.             FindPackages arrPackGuids, GetOIDString(roTemp2.VersionID), iTotalItems, strDirection
  768.             Set roTemp2 = Nothing
  769.           Next
  770.           Set roTemp = Nothing
  771.         End If
  772.         
  773.         ReDim Preserve arrPackGuids(iTotalItems)
  774.         
  775. End Sub
  776.  
  777. '  this function will start at the transformableobject and go back to the package for
  778. '  any object that supports the ITransformableObject interface. The flag determines if this is a source or target
  779. Sub FindPackages(arrIn, ByVal strGuid, iItems, strSourceTarget)
  780.       Dim roStart
  781.       Dim iNumTransformSets, iCntTransformSets
  782.       Dim roTransformSet
  783.       Dim iNumTransform, iCntTransform
  784.       Dim roTransform
  785.       Dim iNumTransformTask, iCntTransformTask
  786.       Dim roTransformTask
  787.       Dim iNumTransformPackage, iCntTransformPackage
  788.       Dim roTransformPackage
  789.       
  790.       
  791.       Set roStart = rRepos.Version(strGuid)
  792.       iNumTransformSets = roStart("ITfmTransformableObject").TransformSets.Count
  793.       For iCntTransformSets = 1 To iNumTransformSets
  794.         Set roTransformSet = roStart("ITfmTransformableObject").TransformSets(iCntTransformSets)
  795.         If strSourceTarget = "source" Then
  796.           iNumTransform = roTransformSet("ITfmTransformableObjectSet").SourceOf.Count
  797.         Else
  798.           iNumTransform = roTransformSet("ITfmTransformableObjectSet").TargetOf.Count
  799.         End If
  800.         
  801.         For iCntTransform = 1 To iNumTransform
  802.           If strSourceTarget = "source" Then
  803.             Set roTransform = roTransformSet("ITfmTransformableObjectSet").SourceOf(iCntTransform)
  804.           Else
  805.             Set roTransform = roTransformSet("ITfmTransformableObjectSet").TargetOf(iCntTransform)
  806.           End If
  807.           
  808.           iNumTransformTask = roTransform("IUmlMember").Type.Count
  809.           
  810.           For iCntTransformTask = 1 To iNumTransformTask
  811.             Set roTransformTask = roTransform("IUmlMember").Type(iCntTransformTask)
  812.             
  813.             iNumTransformPackage = roTransformTask("IUmlElement").package.Count
  814.             
  815.             For iCntTransformPackage = 1 To iNumTransformPackage
  816.               Set roTransformPackage = roTransformTask("IUmlElement").package(iCntTransformPackage)
  817.               If VerifyInterfaceSupport(roTransformPackage, strITfmTransformationPackage) Then
  818.                 AddStrGuidToArray GetOIDString(roTransformPackage.VersionID), arrIn, iItems
  819.                 
  820.               End If
  821.               Set roTransformPackage = Nothing
  822.             Next
  823.             Set roTransformTask = Nothing
  824.           Next
  825.           
  826.         Set roTransform = Nothing
  827.         Next
  828.         Set roTransformSet = Nothing
  829.       Next
  830.       
  831. End Sub
  832.  
  833. '   this will add a package guid to an array, making sure there are no duplicates,
  834. '   it will also increment the total items
  835. Sub AddStrGuidToArray(strGuid, arrIn, iNumItems)
  836.       Dim iCnt
  837.       Dim bFound
  838.         
  839.         bFound = False
  840.         For iCnt = 0 To iNumItems - 1
  841.           If arrIn(iCnt) = strGuid Then
  842.             bFound = True
  843.             Exit For
  844.           End If
  845.         Next
  846.                 
  847.         If Not bFound Then
  848.           iNumItems = iNumItems + 1
  849.           CheckArraySize arrIn, iNumItems
  850.           arrIn(iNumItems - 1) = strGuid
  851.         End If
  852.         
  853. End Sub
  854.  
  855.  
  856. ' **********************************************************
  857. '  findSrcTgtGuidsSrc
  858. '
  859. '  Finds all the source objects for a table or column.
  860. '  The returned array of objects contains object GUIDs and if
  861. '  it is a table or column.  The input is a GUID and an
  862. '  indicator if the input is a table or column.
  863. ' **********************************************************
  864. Sub findSrcTgtGuidsSrc(arrSources, strGuid, strType, iTotalItems)
  865.         Call findSrcTgtGuids(arrSources, strGuid, strType, "target", iTotalItems)
  866. End Sub
  867.  
  868. ' **********************************************************
  869. '  findSrcTgtGuidsTgt
  870. '
  871. '  Finds all the destination objects for a table or column.
  872. '  The returned array of objects contains object GUIDs and if
  873. '  it is a table or column.  The input is a GUID and an
  874. '  indicator if the input is a table or column.
  875. ' **********************************************************
  876. Sub findSrcTgtGuidsTgt(arrTargets, strGuid, strType, iTotalItems)
  877.         Call findSrcTgtGuids(arrTargets, strGuid, strType, "source", iTotalItems)
  878. End Sub
  879.  
  880. ' **********************************************************
  881. '  findSrcTgtGuidsSrc
  882. '
  883. '  Finds all the source or target objects for a table or column.
  884. '  The returned array of objects contains object GUIDs and if
  885. '  it is a table or column.  The input is a GUID and an
  886. '  indicator if the input is a table or column.
  887. ' **********************************************************
  888. Sub findSrcTgtGuids(arrSources, strGuid, strType, strSourceTarget, iTotalItems)
  889.         ReDim arrSources(0, 1)  ' in case of error or not found
  890.         Dim roTemp
  891.         Dim iNum, iCnt
  892.         Dim roTemp2
  893.         
  894.         iTotalItems = 0
  895.         If (strType = "table") Then
  896.           FindSrcTgtObjs arrSources, strGuid, iTotalItems, strSourceTarget
  897.           Set roTemp = rRepos.Version(strGuid)
  898.           iNum = roTemp("IUmlType").Members.Count
  899.           For iCnt = 1 To iNum
  900.             Set roTemp2 = roTemp("IUmlType").Members(iCnt)
  901.             FindSrcTgtObjs arrSources, GetOIDString(roTemp2.VersionID), iTotalItems, strSourceTarget
  902.             Set roTemp2 = Nothing
  903.           Next
  904.           Set roTemp = Nothing
  905.         Else    'column
  906.           FindSrcTgtObjs arrSources, strGuid, iTotalItems, strSourceTarget
  907.         End If
  908. End Sub
  909.  
  910. '   this will start at transformableobject and follow the loop around to any source or target objects on the
  911. '   other side of the transformations
  912. Sub FindSrcTgtObjs(arrIn, strGuid, iItems, strSourceTarget)
  913.       Dim roStart
  914.       Dim iNumTransformSets, iCntTransformSets
  915.       Dim roTransformSet
  916.       Dim iNumTransform, iCntTransform
  917.       Dim roTransform
  918.       Dim iNumOtherTransformSet, iCntOtherTransformSet
  919.       Dim roOtherTransformSet
  920.       Dim iNumOtherTransformableObject, iCntOtherTransformableObject
  921.       Dim roOtherTransformableObject
  922.       
  923.       
  924.       Set roStart = rRepos.Version(strGuid)
  925.       iNumTransformSets = roStart("ITfmTransformableObject").TransformSets.Count
  926.       For iCntTransformSets = 1 To iNumTransformSets
  927.         Set roTransformSet = roStart("ITfmTransformableObject").TransformSets(iCntTransformSets)
  928.         If strSourceTarget = "source" Then
  929.           iNumTransform = roTransformSet("ITfmTransformableObjectSet").SourceOf.Count
  930.         Else
  931.           iNumTransform = roTransformSet("ITfmTransformableObjectSet").TargetOf.Count
  932.         End If
  933.         
  934.         For iCntTransform = 1 To iNumTransform
  935.           If strSourceTarget = "source" Then
  936.             Set roTransform = roTransformSet("ITfmTransformableObjectSet").SourceOf(iCntTransform)
  937.           Else
  938.             Set roTransform = roTransformSet("ITfmTransformableObjectSet").TargetOf(iCntTransform)
  939.           End If
  940.           
  941.           If strSourceTarget = "source" Then
  942.             iNumOtherTransformSet = roTransform("ITfmTransformation").TransformTarget.Count
  943.           Else
  944.             iNumOtherTransformSet = roTransform("ITfmTransformation").TransformSource.Count
  945.           End If
  946.                     
  947.           For iCntOtherTransformSet = 1 To iNumOtherTransformSet
  948.             If strSourceTarget = "source" Then
  949.               Set roOtherTransformSet = roTransform("ITfmTransformation").TransformTarget(iCntOtherTransformSet)
  950.             Else
  951.               Set roOtherTransformSet = roTransform("ITfmTransformation").TransformSource(iCntOtherTransformSet)
  952.             End If
  953.                         
  954.             iNumOtherTransformableObject = roOtherTransformSet("ITfmTransformableObjectSet").TransformObjects.Count
  955.             
  956.             For iCntOtherTransformableObject = 1 To iNumOtherTransformableObject
  957.               Set roOtherTransformableObject = roOtherTransformSet("ITfmTransformableObjectSet").TransformObjects(iCntOtherTransformableObject)
  958.               If VerifyInterfaceSupport(roOtherTransformableObject, strIDbmTable) Then
  959.                 AddTabGuidToSrcTgtArray GetOIDString(roOtherTransformableObject.VersionID), arrIn, iItems
  960.               ElseIf VerifyInterfaceSupport(roOtherTransformableObject, strIDbmDeployedColumn) Then
  961.                 AddColGuidToSrcTgtArray GetOIDString(roOtherTransformableObject.VersionID), arrIn, iItems
  962.               End If
  963.               Set roOtherTransformableObject = Nothing
  964.             Next
  965.             Set roOtherTransformSet = Nothing
  966.           Next
  967.           
  968.         Set roTransform = Nothing
  969.         Next
  970.         Set roTransformSet = Nothing
  971.       Next
  972.       
  973. End Sub
  974.  
  975. '   this will add a table guid to an array, making sure there are no duplicates,
  976. '   it will also increment the total items
  977. Sub AddTabGuidToSrcTgtArray(strGuid, arrIn, iNumItems)
  978.       Dim iCnt
  979.       Dim bFound
  980.         
  981.         bFound = False
  982.         For iCnt = 0 To iNumItems - 1
  983.           If arrIn(iCnt, 0) = strGuid Then
  984.             bFound = True
  985.             Exit For
  986.           End If
  987.         Next
  988.                 
  989.         If Not bFound Then
  990.           iNumItems = iNumItems + 1
  991.           CheckDim2ArraySize arrIn, iNumItems
  992.           arrIn(iNumItems - 1, 0) = strGuid
  993.           arrIn(iNumItems - 1, 1) = "table"
  994.         End If
  995.         
  996. End Sub
  997.  
  998. '   this will add a column guid to an array, making sure there are no duplicates,
  999. '   it will also increment the total items
  1000. Sub AddColGuidToSrcTgtArray(strGuid, arrIn, iNumItems)
  1001.       Dim iCnt
  1002.       Dim bFound
  1003.         
  1004.         bFound = False
  1005.         For iCnt = 0 To iNumItems - 1
  1006.           If arrIn(iCnt, 0) = strGuid Then
  1007.             bFound = True
  1008.             Exit For
  1009.           End If
  1010.         Next
  1011.                 
  1012.         If Not bFound Then
  1013.           iNumItems = iNumItems + 1
  1014.           CheckDim2ArraySize arrIn, iNumItems
  1015.           arrIn(iNumItems - 1, 0) = strGuid
  1016.           arrIn(iNumItems - 1, 1) = "column"
  1017.         End If
  1018.         
  1019. End Sub
  1020.  
  1021.  
  1022. '   this will update the comments and description for a given GUID
  1023. Sub UpdateDescriptions(strGuid, ByVal strDesc, ByVal strComments)
  1024.         Dim roTemp
  1025.         
  1026.         rRepos.Transaction.Begin
  1027.         Set roTemp = rRepos.Version(strGuid)
  1028.         roTemp("ISummaryInformation").ShortDescription = strDesc
  1029.         roTemp("ISummaryInformation").Comments = strComments
  1030.         rRepos.Transaction.Commit
  1031.         
  1032.         
  1033. End Sub
  1034.  
  1035. ' **********************************************************
  1036. '  checkdim2arraysize
  1037. '
  1038. '  verifies the array is big enough, and makes it bigger if not
  1039. '   uses the intialsize and increment constants to resize
  1040. ' **********************************************************
  1041. Sub CheckDim2ArraySize(arrIn, iItems)
  1042.  
  1043.     If iItems > UBound(arrIn, 1) Then
  1044.       If UBound(arrIn, 1) = 0 Then
  1045.         ReDim arrIn(iInitialArraySize, 1)
  1046.       Else
  1047.         ReDim Preserve arrIn(iItems + iArrayIncrement, 1)
  1048.       End If
  1049.     End If
  1050.   
  1051. End Sub
  1052.  
  1053.  
  1054. Function GetOIDString(ByVal ObjectID)
  1055.         Dim strTemp
  1056.         
  1057.     GetOIDString = objSQLNSContext.ReposOIDToString(ObjectID)
  1058.        
  1059.  
  1060. End Function
  1061.